package com.biziit.taxi.connect;

import java.io.*;
import java.net.*;
import java.util.Arrays;

import com.biziit.taxi.connect.Message.Register;
import com.biziit.taxi.connect.Message.UserType;
import com.biziit.taxi.connect.Package.UWirelessTransfer;


public class Connection {
	Socket socket;
	DataInputStream in;
	OutputStream out;

	public Connection() {
		try {
			byte[] reg = Register.getDefaultInstance().newBuilder()
					.setID("lym").setPassword("yanming")
					.setValidCode("aabc")
					.setType(com.biziit.taxi.connect.Message.UserType.Passager).build()
					.toByteArray();
			byte[] ustart=new Package.UStart(null,null,BitConverter.getBytes("809274011088953")).getBytes();
			final UWirelessTransfer uwt = new UWirelessTransfer((byte)0, MessageUtil.joinBytes(BitConverter.getBytes(MessageType.Register.getMessageType()),reg), (byte)0);
			final byte[] bs = { (byte) 0xd0, 0x01, 0x00, 0x64, 0x00, 0x00,
					0x00, 0x01, 0x00, 0x00, 0x00 };
			Package.getInstance().startWork();
			Package.getInstance().getSentPackage().put(ustart);
			Object obj=Package.getInstance().getReceivedPackage().take();
			System.out.println(obj);
		}  catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}



	public static void main(String[] args) {
		 //new Connection();
		// (byte) 0xd0 ,0x01, 0x00, 0x64, 0x00,0x00, 0x00, 0x01, 0x00, 0x00,
		// 0x00
		/*byte[] bs = new Package.UMDTINFO(new byte[] { 0x01 },
				new byte[] { 0x64 }, new byte[] { 0x01, 0x00, 0x00, 0x00 })
				.getBytes();*/
		System.out.println((byte)0xB9==(byte)-71);
	}
}